/**
 * 系统相关的 IPC 客户端模块
 */
import { invoke } from '../ipc'

/**
 * 获取系统信息
 * @returns 系统信息
 */
export async function getSystemInfo(): Promise<{
  platform: string
  arch: string
  cpus: any[]
  totalMemory: number
  freeMemory: number
  uptime: number
  hostname: string
  userInfo: any
  release: string
  type: string
  networkInterfaces: any
}> {
  return await invoke('get-system-info')
}

/**
 * 获取CPU使用情况
 * @returns CPU使用情况
 */
export async function getCpuUsage(): Promise<{
  success: boolean
  cpuCount?: number
  loadAvg?: number[]
  model?: string
  speed?: number
  error?: string
}> {
  return await invoke('get-cpu-usage')
}

/**
 * 获取内存使用情况
 * @returns 内存使用情况
 */
export async function getMemoryUsage(): Promise<{
  success: boolean
  totalMemory?: number
  freeMemory?: number
  usedMemory?: number
  usedPercent?: number
  processMemory?: any
  error?: string
}> {
  return await invoke('get-memory-usage')
}

/**
 * 获取磁盘信息
 * @returns 磁盘信息
 */
export async function getDiskInfo(): Promise<{
  success: boolean
  data?: string
  error?: string
}> {
  return await invoke('get-disk-info')
}

/**
 * 获取网络信息
 * @returns 网络信息
 */
export async function getNetworkInfo(): Promise<{
  success: boolean
  networkInterfaces?: any
  error?: string
}> {
  return await invoke('get-network-info')
} 